package com.atguigu.gulimall.member.web;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
public class MemberWebController {

    @Autowired
    OrderFeignService orderFeignService;

    /**
     * 查出当前用户所有订单列表数据
     */
    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum,
                                  Model model, HttpServletRequest request){



        Map<String,Object> map = new HashMap<>();
        map.put("page",pageNum.toString());
        //远程调用->订单服务，获取当前登录用户的所有订单列表信息
        R r = orderFeignService.listWithItem(map);
        model.addAttribute("orders",r);

        return "orderList";
    }
}
